package net.hmapp.app.api;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import net.hmapp.app.interfaces.ResponseCallback;
import net.hmapp.app.viewmodel.HomeData;
import net.hmapp.app.viewmodel.ResponseData;

public class ApiService {

    private static final String baseURL = "http://hmapp.net:8888/";

    public static void GetHome(ResponseCallback<ResponseData<HomeData>> callback) {
        OkGo.<String>get(baseURL + "/wx/home/index")
//                .tag(this)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        ResponseData<HomeData> result=new Gson().fromJson(response.body(),new TypeToken<ResponseData<HomeData>>(){}.getType());

                        callback.onSuccess(result);
                    }
                });

    }


}
